/**
 * Copyright (C) 2011 PROCESSBASE Ltd.
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GPL as published by the Free Software Foundation version 3 of the License.
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with this
 * program; if not, see <http://www.gnu.org/licenses/>.
 */
package org.processbase.touchprocess.ui.demo;

import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
//import com.invient.vaadin.charts.Color.RGB;
//import com.invient.vaadin.charts.InvientCharts;
//import com.invient.vaadin.charts.InvientCharts.DecimalPoint;
//import com.invient.vaadin.charts.InvientCharts.SeriesType;
//import com.invient.vaadin.charts.InvientCharts.XYSeries;
//import com.invient.vaadin.charts.InvientChartsConfig;
//import com.invient.vaadin.charts.InvientChartsConfig.GeneralChartConfig.Margin;
//import com.invient.vaadin.charts.InvientChartsConfig.PieConfig;
//import com.invient.vaadin.charts.InvientChartsConfig.PieDataLabel;
//import com.invient.vaadin.charts.InvientChartsConfig.PointConfig;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Random;

/**
 *
 * @author marat
 */
public class PieChartDemo extends VerticalLayout {

//    private HashMap<String, RGB> colors = new HashMap<String, RGB>();
//
//    public void initUI() {
//        try {
//            PieConfig pieCfg1 = new PieConfig();
//            pieCfg1.setAnimation(true);
//            pieCfg1.setDataLabel(new PieDataLabel(true));
//            pieCfg1.setColor(new RGB(100, 100, 100));
//            pieCfg1.getDataLabel().setConnectorColor(new RGB(100, 100, 100));
//            pieCfg1.setAllowPointSelect(true);
//            pieCfg1.setShowInLegend(true);
//
//            XYSeries series1 = new XYSeries("Browsers", SeriesType.PIE, pieCfg1);
//            LinkedHashSet<DecimalPoint> points1 = new LinkedHashSet<DecimalPoint>();
//
//            DecimalPoint point1 = new DecimalPoint(series1, "Firefox", 40.0);
//            point1.setConfig(new PointConfig(new RGB(230, 0, 0)));
//            points1.add(point1);
//            point1 = new DecimalPoint(series1, "Chrome", 30.0);
//            point1.setConfig(new PointConfig(new RGB(0, 230, 0)));
//            points1.add(point1);
//            point1 = new DecimalPoint(series1, "IE", 13.0);
//            point1.setConfig(new PointConfig(new RGB(0, 0, 230)));
//            points1.add(point1);
//            point1 = new DecimalPoint(series1, "Safari", 20.0);
//            point1.setConfig(new PointConfig(new RGB(230, 230, 0)));
//            points1.add(point1);
//            point1 = new DecimalPoint(series1, "Other", 3.0);
//            point1.setConfig(new PointConfig(new RGB(230, 0, 230)));
//            points1.add(point1);
//
//            series1.setSeriesPoints(points1);
//
//            InvientCharts ich2 = createchart(series1);
//            ich2.setWidth("100%");
//            ich2.setHeight("100%");
//            addComponent(ich2);
//
//
//        } catch (Exception ex) {
//            ex.printStackTrace();
//        }
//    }
//
//    private InvientCharts createchart(XYSeries series1) {
//        InvientChartsConfig chartConfig = new InvientChartsConfig();
//        chartConfig.getGeneralChartConfig().setType(SeriesType.PIE);
//        chartConfig.getSubtitle().setText("Source: PROCESSBASSE BPMS");
//
//        chartConfig.getGeneralChartConfig().setMargin(new Margin());
//        chartConfig.getGeneralChartConfig().getMargin().setTop(50);
//        chartConfig.getGeneralChartConfig().getMargin().setRight(0);
//        chartConfig.getGeneralChartConfig().getMargin().setBottom(0);
//        chartConfig.getGeneralChartConfig().getMargin().setLeft(0);
//        chartConfig.setLegend(new InvientChartsConfig.Legend(true));
//        chartConfig.getTitle().setText("PieChart Demo");
//
//        chartConfig.getTooltip().setFormatterJsFunc(
//                "function() {"
//                + " return '<b>'+ this.series.name +'</b><br/>'+ "
//                + "     this.point.name +': '+ this.y; " + "}");
//
//        InvientCharts chart = new InvientCharts(chartConfig);
//        chart.addSeries(series1);
////        chart.addSeries(series2);
//        return chart;
//
//    }
//
//    private RGB getColor(String name) {
//        if (colors.containsKey(name)) {
//            return colors.get(name);
//        } else {
//            Random x = new Random();
//            RGB rgb = new RGB(x.nextInt(255), x.nextInt(255), x.nextInt(255));
//            colors.put(name, rgb);
//            return rgb;
//        }
//    }
}
